home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / gfx / edit / VE-scaler.lha / arexx / Scaler.rexx
OS/2 REXX Batch file  |  1999-01-23  |  3KB  |  144 lines

  1. /*
  2.  
  3.    v1.15 Scaler
  4.  
  5.    Marko Seppänen
  6.    marko.seppanen@wwnet.fi
  7.  
  8. */
  9.  
  10.  
  11. address IMAGEENGINEER
  12.  
  13. Options results
  14. signal on error            /* Setup a place for errors to go */
  15.  
  16. x=arg(1)
  17. text=subword(x,1,1)
  18. type=space(subword(x,2,1),0)
  19.  
  20.  
  21. 'GET_FILES "Choose some pictures..." "Ok" "gfx:"'
  22. filelist=result
  23. if RC=5 then exit
  24.  
  25.  
  26.  
  27. /*  HOW MANY PHILEZ  */
  28.  
  29. files=0
  30.  
  31. filist=filelist
  32.  
  33. do while filist~=""
  34.   parse var filist pic ';' filist
  35.   files=files+1
  36. end
  37.  
  38. if files=1 then do
  39.   'REQUEST "Only one picture ??" "Sorry"'
  40.   exit
  41. end
  42.  
  43.  
  44.  
  45.  
  46. if exists("ie:prefs/VEScaler.cfg") == "1" then
  47.   do
  48.     call open("temp","ie:prefs/VEScaler.cfg","R")
  49.     values=readln("temp")
  50.     parse var values ok max min aspect .
  51.     call close("temp")
  52.   end
  53. else
  54.   do
  55.     max=100
  56.     min=70
  57.     aspect=1
  58.   end
  59.  
  60. 'FORM "Scaler" "Use|Cancel"',
  61. ' INTEGER,"Maximum X",8,1000,'max',SLIDER',
  62. ' INTEGER,"Minimum %",1,100,'min',SLIDER',
  63. ' CHECKBOX,"Aspect correct",'aspect''
  64.  
  65. values=result
  66. parse var values ok max min aspect .
  67. if ok = 0 then exit
  68.  
  69. call open("temp","ie:prefs/VEScaler.cfg","W")
  70. res=writeln("temp",values)
  71. call close("temp")
  72.  
  73.  
  74.  
  75.  
  76. minimum=max/100*min
  77. temp=(max-minimum)/(files-1)
  78. ListOfPics=""
  79.  
  80. do i=0 to files-1
  81.  
  82.   parse var filelist pic ';' filelist
  83.   OPEN "'"pic"'" COLOUR
  84.   pic=result
  85.   MARK pic PRIMARY
  86.   PROJECT_INFO pic WIDTH
  87.   picwidth=result
  88.   PROJECT_INFO pic HEIGHT
  89.   picheight=result
  90.  
  91.   step=temp*i
  92.  
  93.  
  94.   if aspect=="1" then do
  95.  
  96.     aspectvalue=1-((picwidth-max)/picwidth)
  97.     ysize=picheight*aspectvalue
  98.  
  99.     SCALE pic max-step ysize-step BEST
  100.     pic2=result
  101.  
  102.   end
  103.   else do
  104.  
  105.     SCALE pic minimum+step minimum+step BEST
  106.     pic2=result
  107.  
  108.   end
  109.  
  110.   ListOfPics=insert(ListOfPics,pic2)
  111.   ListOfPics=insert(ListofPics,";")
  112.  
  113.   CLOSE pic
  114.  
  115. end
  116.  
  117.  
  118. if text="GimmeSumScaledPics" then do
  119.   ListOfPics=delstr(ListOfPics,length(ListOfPics),1)
  120.   call open("tempfile","ram:List-o-Pictures.file","W")
  121.   call writeln("tempfile",ListOfPics)
  122.   call close("tempfile")
  123. end
  124.  
  125. exit
  126.  
  127. /*******************************************************************/
  128. /* This is where control goes when an error code is returned by IE */
  129. /* It puts up a message saying what happened and on which line     */
  130. /*******************************************************************/
  131. error:
  132. if RC=5 then do            /* Did the user just cancel us? */
  133.     IE_TO_FRONT
  134.     LAST_ERROR
  135.     'REQUEST "'||RESULT||'"'
  136.     exit
  137. end
  138. else do
  139.     IE_TO_FRONT
  140.     LAST_ERROR
  141.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  142.     exit
  143. end
  144.